﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcmyjobs.Web
{
    public partial class article : BasePage
    {
        lcmyjobs.BLL.news bn = new BLL.news();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.lbl_time.Text = System.DateTime.Now.GetDateTimeFormats('D')[3].ToString();
                int id = int.Parse(Application["webid"].ToString());
                if (Request.QueryString["nid"] != null)
                {
                    try
                    {
                        int nid = int.Parse(Request.QueryString["nid"]);
                        DataSet ds = bn.GetNews(nid);
                        if (ds.Tables[0].Rows.Count > 0)
                        {

                            //ntitle, ntime,truename,ntname,ncontent,ntid                    
                            this.lbltitle.Text = ds.Tables[0].Rows[0][0].ToString();
                            this.lbltime.Text = DateTime.Parse(ds.Tables[0].Rows[0][1].ToString()).ToString("yyyy-M-d");
                            lblcome.Text = ds.Tables[0].Rows[0][2].ToString();
                            this.lblcontent.Text = ds.Tables[0].Rows[0][4].ToString();
                            //NewsList1.count = 30;
                            NewsList1.count = 10;
                            NewsList1.typeid = int.Parse(ds.Tables[0].Rows[0][5].ToString());
                            //NewsList1.infourl = "article.html";
                            NewsList1.infourl = "../article";
                            ltitle.Text = ds.Tables[0].Rows[0][3].ToString();
                            this.Title = string.Format("{3}猎头网   {3}人才网   {3}招聘网   {3}求职网   {0}—{2}：{1}", Application["webname"].ToString(), ds.Tables[0].Rows[0][0].ToString(), ltitle.Text, Application["webregion"].ToString());
                        }
                    }
                    catch (Exception ex)
                    {


                    }

                }
                else if (Request.QueryString["ntid"] != null)
                {
                    try
                    {
                        int aid = int.Parse(Request.QueryString["ntid"]);
                        NewsList1.count = 30;
                        NewsList1.typeid = aid;
                        //NewsList1.infourl = "article.html";
                        NewsList1.infourl = "../article";
                        lcmyjobs.BLL.news_type nt = new BLL.news_type();
                        ltitle.Text = nt.GetModel(aid).ntname;
                        this.Title = string.Format("猎头网   人才网   招聘网   求职网   {0}—{1}", Application["webname"].ToString(), ltitle.Text);

                        lcmyjobs.BLL.news nm = new lcmyjobs.BLL.news();

                        DataSet ds_ntids = nm.GetListNews(id, 1, aid);

                        if (ds_ntids.Tables[0].Rows.Count > 0)
                        {
                            DataSet ds = nm.GetList(" nid=" + Convert.ToInt32(ds_ntids.Tables[0].Rows[0][0].ToString()));
                            this.lbltitle.Text = ds.Tables[0].Rows[0]["ntitle"].ToString();
                            this.lbltime.Text = DateTime.Parse(ds.Tables[0].Rows[0]["ntime"].ToString()).ToString("yyyy-M-d");
                            lblcome.Text = ds.Tables[0].Rows[0]["truename"].ToString();
                            this.lblcontent.Text = ds.Tables[0].Rows[0]["ncontent"].ToString();

                        }



                    }
                    catch (Exception ex)
                    {


                    }

                }
            }

        }
    }
}